export default {
  namespaced: true,
  state: {
    token: localStorage.getItem('token') || '',
    role: localStorage.getItem('role') || '',
    userInfo: localStorage.getItem('userInfo')
      ? JSON.parse(localStorage.getItem('userInfo'))
      : {}
  },
  mutations: {
    // 设置用户信息
    SET_USER (state, { token, role, userInfo }) {
      state.token = token
      state.role = role
      state.userInfo = userInfo
    },
    // 移除用户信息  为了 退出登录
    RM_USER_INFO (state) {
      localStorage.removeItem('token')
      localStorage.removeItem('role')
      localStorage.removeItem('userInfo')
    }
  }
}
